﻿<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="SecurityManagement.aspx.cs"
    Inherits="Medianamik.UI.ContentManagement.SecurityManagement" MasterPageFile="../MasterPages/MedianamikModule.Master" %>
<%@ Import Namespace="Medianamik.Core.Security" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" %>
<%@ Register TagPrefix="med" Namespace="Medianamik.UI.Controls" %>
<%@ Register TagPrefix="lock" Namespace="Medianamik.UI.Lock" %>

<asp:Content ID="HeaderContentHolder" runat="server" ContentPlaceHolderID="HeaderContentHolder">
</asp:Content>
<asp:Content ID="ContextMenuContent" ContentPlaceHolderID="ContextMenu" runat="server">
    <asp:LinkButton ID="saveButton" runat="server" CssClass="Action BtSauvegarder" OnClick="SavePermissionsAndApprobations"
        Text="<%$ Resources: Medianamik_Global, SaveButtonText %>" />
    <a href="<%= ReturnURL %>" class="Action BtAnnuler"><asp:Literal runat="server" Text="<%$ Resources: Medianamik_Global, Cancel %>"></asp:Literal></a>
</asp:Content>
<asp:Content ID="CenterContent" ContentPlaceHolderID="CenterContent" runat="server">
    <med:BreadcrumbTrail ID="bctFilAriane" runat="server" CssClass="FilAriane" CurrentPageAsLink="false"
                Url="nodelist.aspx" ParamName="parent" Separator="" />
   <telerik:RadTabStrip ID="RadTabStrip1" MultiPageID="RadMultiPage1" runat="server"
        Skin="Medianamik" EnableEmbeddedSkins="false" CausesValidation="false" ShowBaseLine="True">
        <Tabs>
            <telerik:RadTab Text="<%$ Resources: Medianamik_Tabs, SecurityTabName %>" PageViewID="Security" Selected="true" />
            <telerik:RadTab ID="tabApprobation" Text="<%$ Resources: Medianamik_Tabs, ApprobationTabName %>" Visible="false" PageViewID="Approbation" />
        </Tabs>
    </telerik:RadTabStrip>
    <telerik:RadMultiPage ID="RadMultiPage1" SelectedIndex="0" runat="server" CssClass="TabPage">
        <telerik:RadPageView ID="Security" runat="server" CssClass="ContainerEditeurPage">
            <h2><%= Resources("Medianamik_Tabs", "SecurityManagementTitle") %></h2>
            <med:NodePermissionSelector ID="nodePermissionSelector" runat="server" />
        </telerik:RadPageView>
        <telerik:RadPageView ID="Approbation" runat="server" Visible="false" CssClass="ContainerEditeurPage">
            <h2><%= Resources("Medianamik_Tabs", "ApprobationManagementTitle") %></h2>
            <% if (!ApprobationIsOwned) { %>&nbsp;<p><i><%= Resources("Medianamik_SecurityManagement", "ApprobationInherited")%></i></p><% } %>
            <br />
            <p><asp:HyperLink ID="AddGroup" runat="server" CssClass="Btn"><%= Resources("Medianamik_SecurityManagement", "AddGroup")%></asp:HyperLink>
            <% if (ApprobationIsOwned) { %>&nbsp;<asp:LinkButton ID="DefaultGroups" runat="server" CssClass="Btn" OnClientClick="return confirmDefaultGroups();" ><%= Resources("Medianamik_SecurityManagement", "DefaultGroups")%></asp:LinkButton><% } %></p>
            <telerik:RadGrid ID="GroupGrid"
                             runat="server"
                             Skin="Medianamik"
                             EnableEmbeddedSkins="false"
                             OnNeedDataSource="DataBindGroupItems"
                             AutoGenerateColumns="false"
                             OnRowDrop="OnApprobationItemRowDrop">
                <MasterTableView>
                    <NoRecordsTemplate>
                        <asp:Literal ID="noRecords" runat="server" Text="<%$ Resources: Medianamik_ContentManagement, NoRecordsToDisplay %>" />
                    </NoRecordsTemplate>
                    <Columns>
                        <telerik:GridTemplateColumn HeaderStyle-Width="1%" DataField="DisplayName">
                            <HeaderTemplate>
                                <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources: Medianamik_ContentManagement, ContentApprobationLevelColumn %>" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <%# ((GroupItem)Container.DataItem).Index %>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn DataField="DisplayName">
                            <HeaderTemplate>
                                <asp:Literal runat="server" Text="<%$ Resources: Medianamik_ContentManagement, ContentNameColumn %>" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:HiddenField ID="GroupId" runat="server" Value="<%# ((GroupItem)Container.DataItem).Id %>" />
                                <%# ((GroupItem)Container.DataItem).Name %>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderStyle-Width="1%" HeaderText="Actions">
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle CssClass="Actions" />
                            <ItemTemplate>
                                <table border="0" cellpadding="0" cellspacing="0" align="center">
                                    <tr>
                                        <td><med:ConfirmedImageButton ID="DeleteGroup"
                                                CommandArgument='<%# ((GroupItem)Container.DataItem).Id %>'
                                                title="<%$ Resources: Medianamik_Global, Action_DeleteTooltip %>"
                                                CommandName="DeleteGroup"
                                                ImageUrl="/medianamik/images/Icones/Ico_Supprimer.gif"
                                                runat="server"
                                                ConfirmText="<%$ Resources: Medianamik_SecurityManagement, ConfirmDeleGroupText %>" />
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
                <ClientSettings AllowRowsDragDrop="True" EnableRowHoverStyle="true">
                    <Selecting AllowRowSelect="True" EnableDragToSelectRows="true" />
                    <ClientEvents OnRowDropping="onRowDropping" />
                </ClientSettings>
            </telerik:RadGrid>
            <asp:HiddenField ID="SelectedGroupName" runat="server" />
            <asp:HiddenField ID="SelectedGroupNodeId" runat="server" />
            <asp:Button ID="SubmitSelectedGroupNodeId" runat="server" OnClick="AddApprobationItem" style="display: none;" />
        </telerik:RadPageView>
    </telerik:RadMultiPage>
    <lock:LockActivator ID="SecurityLockActivator" runat="server" />
</asp:Content>
<asp:Content ID="ExternalContent" ContentPlaceHolderID="ExternalContentHolder" runat="server">
        <telerik:RadScriptBlock runat="server" ID="scriptBlock">
            <script type="text/javascript">
                //<![CDATA[

                function onGroupSelected(sender, args) {
                    var arg = args.get_argument();
                    if (arg && arg.NodeTypeId) {
                        document.getElementById('<%= SelectedGroupName.ClientID %>').value = arg.NodeName;
                        document.getElementById('<%= SelectedGroupNodeId.ClientID %>').value = arg.NodeTypeId;
                        __doPostBack('<%= SubmitSelectedGroupNodeId.UniqueID %>', '');
                    }
                }
                
                function onRowDropping(sender, args) {
                }

                function confirmDefaultGroups() {
                    return confirm('<%= Resources("Medianamik_SecurityManagement", "ConfirmDefaultGroupsText")%>');
                }
                //]]>
            </script>
        </telerik:RadScriptBlock>
</asp:Content>